/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.floatwindow.floattingicon;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;

@SuppressLint({ "HandlerLeak" })
public class RotateIconView extends View {
    private int a = 0;
    private float b = 0.0F;
    private Context c;
    private Bitmap[] d = null;
    private Rect e = new Rect();
    private Rect f = new Rect();

    public void a() {
        if ((this.d == null) || (this.d.length <= 0))
            return;
        this.a += 1;
        if (this.a >= this.d.length)
            this.a = 0;
        this.b += 5.0F;
        if (this.b > 360.0F)
            this.b = 0.0F;
        invalidate();
    }

    public RotateIconView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) {
        super(paramContext, paramAttributeSet, paramInt);
        a(paramContext);
    }

    public RotateIconView(Context paramContext, AttributeSet paramAttributeSet) {
        super(paramContext, paramAttributeSet);
        a(paramContext);
    }

    public RotateIconView(Context paramContext) {
        super(paramContext);
        a(paramContext);
    }

    protected void a(Context paramContext) {
        if (paramContext == null)
            return;
        this.c = paramContext;
        this.e.left = (this.e.right = this.e.top = this.e.bottom = 0);
        this.f.left = (this.f.right = this.f.top = this.f.bottom = 0);
    }

    private void a(Bitmap[] paramArrayOfBitmap, int paramInt1, int paramInt2) {
        if ((paramArrayOfBitmap == null) || (paramInt1 < 0) || (paramInt1 >= paramArrayOfBitmap.length))
            return;
        Bitmap localBitmap = a(paramInt2);
        if (localBitmap == null)
            return;
        if ((this.e.width() == 0) || (this.e.height() == 0)) {
            this.e.right = localBitmap.getWidth();
            this.e.bottom = localBitmap.getHeight();
        }
        paramArrayOfBitmap[paramInt1] = localBitmap;
    }

    public void a(a parama) {
        if (this.d != null)
            return;
        this.d = new Bitmap[4];
        a(this.d, 0, 67108875);
        a(this.d, 1, 67108876);
        a(this.d, 2, 67108877);
        a(this.d, 3, 67108878);
    }

    protected void onDraw(Canvas paramCanvas) {
        if ((paramCanvas == null) || (getVisibility() != 0))
            return;
        int i = getWidth();
        int j = getHeight();
        if ((i <= 0) || (j <= 0))
            return;
        if ((this.f.width() <= 0) || (this.f.height() <= 0)) {
            this.f.left = (this.f.top = 0);
            this.f.right = i;
            this.f.bottom = j;
        }
        paramCanvas.rotate(this.b, i / 2, j / 2);
        a(paramCanvas, this.d, this.a, i, j);
    }

    private int a(Canvas paramCanvas, Bitmap[] paramArrayOfBitmap, int paramInt1, int paramInt2, int paramInt3) {
        if ((paramArrayOfBitmap == null) || (paramArrayOfBitmap.length <= 0))
            return 0;
        if (paramInt1 >= paramArrayOfBitmap.length)
            paramInt1 = 0;
        if (paramInt1 < 0)
            paramInt1 = 0;
        Bitmap localBitmap = paramArrayOfBitmap[paramInt1];
        if ((localBitmap == null) || (localBitmap.isRecycled()))
            return paramInt1;
        paramCanvas.drawBitmap(localBitmap, this.e, this.f, null);
        return paramInt1;
    }

    public void b() {}

    private Bitmap a(int paramInt) {
        byte[] arrayOfByte = com.qihoo.gamecenter.sdk.common.b.a.b(this.c, "360sdk_res/res6.dat", paramInt);
        BitmapFactory.Options localOptions = new BitmapFactory.Options();
        localOptions.inTargetDensity = this.c.getResources().getDisplayMetrics().densityDpi;
        localOptions.inDensity = 320;
        return BitmapFactory.decodeByteArray(arrayOfByte, 0, arrayOfByte.length, localOptions);
    }
}